﻿namespace AB.ServiceDirectory.Dao
{
    using System.Collections.Generic;
    using System.Linq;
    using Entities;

    /// <summary>
    /// ABestContactMethodDao Class
    /// </summary>
    public sealed class ABestContactMethodDao
    {
        /// <summary>
        /// Data Context
        /// </summary>
        private static readonly ServicesDirectoryDataContext Context = DB.Context;

        /// <summary>
        /// Prevents a default instance of the <see cref="ABestContactMethodDao"/> class from being created.
        /// </summary>
        private ABestContactMethodDao()
        {
        }

        /// <summary>
        /// Finds all contact method.
        /// </summary>
        /// <returns></returns>
        public static ICollection<BestContactMethod> FindAllContactMethod()
        {
            IQueryable<BestContactMethod> contactMethod = from c in Context.BestContactMethods select c;
            return contactMethod.ToList();
        }

        /// <summary>
        /// Finds the contact method by id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public static BestContactMethod FindContactMethodById(int id)
        {
            BestContactMethod contactMethod = Context.BestContactMethods.FirstOrDefault(c => c.BestContactMethodId == id);
            return contactMethod;
        }
    }
}